﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using Hxsoft.AppV1.Module;

namespace Hxsoft.AppV1.Admin.FeedBackManage.Controls
{
	public partial class FeedBack : BaseUserControl
	{
		/// <summary>
		/// 属性 FeedBackID
		/// </summary>
		public int FeedBackID
		{
			get
			{
				object val = ViewState["FeedBackID"];

				if (val == null)
				{
					return default(int);
				}
				else
				{
					return (int)val;
				}
			}
			set
			{
				ViewState["FeedBackID"] = value;
				CtrlFeedBackID.Text = value.ToString();
			}
		}

		///// <summary>
		///// 属性 InfoType
		///// </summary>
		//public string InfoType
		//{
		//    get
		//    {
		//        return CtrlInfoType.SelectedValue;
		//    }
		//    set
		//    {
		//        try
		//        {
		//            CtrlInfoType.SelectedValue = value;
		//        }
		//        catch (InvalidOperationException e)
		//        {
		//            //CtrlInfoType.SelectedValue = "文章";
		//        }
		//    }
		//}

		/// <summary>
		/// 属性 url
		/// </summary>
		public string Url
		{
			get
			{
				if (String.IsNullOrEmpty(CtrlUrl.Text))
					return null;

				return Convert.ToString(CtrlUrl.Text);
			}
			set
			{
				if (value == null)
					CtrlUrl.Text = "";
				else
					CtrlUrl.Text = value.ToString();
			}
		}

		/// <summary>
		/// 属性 Summary
		/// </summary>
		public string Summary
		{
		    get
		    {
		        if (String.IsNullOrEmpty(CtrlSummary.Text))
		            return null;

		        return Convert.ToString(CtrlSummary.Text);
		    }
		    set
		    {
		        if (value == null)
		            CtrlSummary.Text = "";
		        else
		            CtrlSummary.Text = value.ToString();
		    }
		}

		 //<summary>
		 //属性 Opinion
		 //</summary>
		public string Opinion
		{
			get
			{
				return Convert.ToString(CtrlOpinion.Text);
			}
			set
			{
				CtrlOpinion.Text = value.ToString();
			}
		}

		/// <summary>
		/// 属性 UserIP
		/// </summary>
		public string UserIP
		{
			get
			{
				if (String.IsNullOrEmpty(CtrlUserIP.Text))
					return null;

				return Convert.ToString(CtrlUserIP.Text);
			}
			set
			{
				if (value == null)
					CtrlUserIP.Text = "";
				else
					CtrlUserIP.Text = value.ToString();
			}
		}

		/// <summary>
		/// 属性 CreateDate
		/// </summary>
		public DateTime CreateDate
		{
			get
			{
				return Convert.ToDateTime(CtrlCreateDate.Text);
			}
			set
			{
				CtrlCreateDate.Text = value.ToString();
			}
		}

		/// <summary>
		/// 属性 UserName
		/// </summary>
		public string UserName
		{
			get
			{
				if (String.IsNullOrEmpty(CtrlUserName.Text))
					return null;

				return Convert.ToString(CtrlUserName.Text);
			}
			set
			{
				if (value == null)
					CtrlUserName.Text = "";
				else
					CtrlUserName.Text = value.ToString();
			}
		}

		/// <summary>
		/// 属性 EMail
		/// </summary>
		public string EMail
		{
			get
			{
				if (String.IsNullOrEmpty(CtrlEMail.Text))
					return null;

				return Convert.ToString(CtrlEMail.Text);
			}
			set
			{
				if (value == null)
					CtrlEMail.Text = "";
				else
					CtrlEMail.Text = value.ToString();
			}
		}

		///// <summary>
		///// 属性 CreatorID
		///// </summary>
		//public Guid? CreatorID
		//{
		//    get
		//    {
		//        if (String.IsNullOrEmpty(CtrlCreatorID.Text))
		//            return null;

		//        ViewState["CreatorID"] = CtrlCreatorID.Text;

		//        return (Guid)ViewState["CreatorID"];
		//    }
		//    set
		//    {
		//        if (value == null)
		//            CtrlCreatorID.Text = "";
		//        else
		//            CtrlCreatorID.Text = value.ToString();
		//    }
		//}

		///// <summary>
		///// 属性 SiteId
		///// </summary>
		//public int? SiteId
		//{
		//    get
		//    {
		//        return IntExtensions.ParseOrNull(CtrlSiteID.Text);
		//    }
		//    set
		//    {
		//        CtrlSiteID.Text = value.ToString();
		//    }
		//}


		/// <summary>
		/// 控件的 FeedBackInfo 实例。
		/// </summary>
		public Module.FeedBack Info
		{
			get
			{
				Module.FeedBack feedBack = new Module.FeedBack();

				feedBack.FeedBackId = FeedBackID;
				//feedBack.InfoType = InfoType;
				feedBack.Url = Url;
				feedBack.Summary = Summary;
				feedBack.Opinion = Opinion;
				feedBack.UserIp = UserIP;
				feedBack.CreationDate = CreateDate;
				feedBack.UserName = UserName;
				feedBack.Email = EMail;
				//feedBack.CreatorId = CreatorID;
				//feedBack.SiteId = SiteId;

				return feedBack;
			}
			set
			{
				if (value == null) return;

				FeedBackID = value.FeedBackId;
				//InfoType = value.InfoType;
				Url = value.Url;
				Summary = value.Summary;
				Opinion = value.Opinion;
				UserIP = value.UserIp;
				CreateDate = value.CreationDate;
				UserName = value.UserName;
				EMail = value.Email;
				//CreatorID = value.CreatorId;
				//SiteId = value.SiteId;
			}
		}


		protected void Page_Load(object sender, EventArgs e)
		{
			if (!this.IsPostBack)
			{
				this.DataBind();
			}
		}
	}
}